package cn.com.cifi.mars.web.action.sys;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSONArray;

import cn.com.cifi.mars.bean.vo.sys.req.DeleteSysProcessConfigReqParam;
import cn.com.cifi.mars.bean.vo.sys.req.SaveSysPositionOrgDataPermissionReqParam;
import cn.com.cifi.mars.bean.vo.sys.req.SaveSysProcessConfigReqParam;
import cn.com.cifi.mars.bean.vo.sys.req.UpdateSysProcessConfigReqParam;
import cn.com.cifi.mars.bean.vo.sys.rsp.OrgTreeVo;
import cn.com.cifi.mars.bean.vo.sys.rsp.RegionVo;
import cn.com.cifi.mars.bean.vo.sys.rsp.SysProcessConfigVo;
import cn.com.cifi.mars.common.bean.R;
import cn.com.cifi.mars.common.constants.VersionConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@Api(tags = {"系统管理"})
@RequestMapping("/${spring.data.rest.base-path}/{apiVersion}/sys/sysProcessConfig")
public interface ISysProcessConfigController {

	@ApiOperation(value = "系统配置-添加流程", notes = "系统配置-添加流程")
	@PostMapping(value = "")
	public R<String> createSysProcessConfig(
			@ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
			@RequestBody SaveSysProcessConfigReqParam param);

	@ApiOperation(value = "系统配置-编辑流程", notes = "系统配置-编辑流程")
	@PutMapping(value = "tree")
	public R<String> updateSysProcessConfig(
			@ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
			@RequestBody UpdateSysProcessConfigReqParam param);

	@ApiOperation(value = "系统配置-流程配置分页", notes = "系统配置-流程配置分页")
	@GetMapping(value = "page")
	public R<SysProcessConfigVo> getSysProcessConfigPage(
			@ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
			@ApiParam(value = "当前第几页", required = true, defaultValue = "1") @RequestParam(value = "current") String current,
	        @ApiParam(value = "每页条数", required = true, defaultValue = "2") @RequestParam(value = "pageSize") String pageSize,
	        @ApiParam(value = "区域id", required = false) @RequestParam(value = "regionId", defaultValue = "") String regionId);

	@ApiOperation(value = "系统配置-删除流程配置", notes = "系统配置-删除流程配置")
	@DeleteMapping(value = "")
	public R<String> deleteSysProcessConfigById(
			@ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
			@RequestBody DeleteSysProcessConfigReqParam param);

	@ApiOperation(value = "导出流程配置", notes = "导出流程配置")
	@GetMapping(value = "export")
    public void export (
    		@ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,HttpServletResponse response,
	        @ApiParam(value = "区域id", required = false) @RequestParam(value = "regionId", defaultValue = "") String regionId);
	
	@ApiOperation(value = "导入流程配置", notes = "导入流程配置")
	@PostMapping(value = "import")
	public R<String> importSysProcessConfig(
			@ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
			@ApiParam(value = "上传文件", required = true) @RequestParam(value = "file", defaultValue = "") MultipartFile file);

	@ApiOperation(value = "流程配置左侧组织机构", notes = "流程配置左侧组织机构")
	@GetMapping(value = "orgTree")
	public R<List<OrgTreeVo>> getOrgTree(
			@ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion);

	@ApiOperation(value = "流程配置编辑时查询区域层级", notes = "流程配置编辑时查询区域层级")
	@GetMapping(value = "rank")
	public R<String> getRank(
			@ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
			@ApiParam(value = "主键id", required = true) @RequestParam(value = "id", defaultValue = "") String id);

}
